home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / emstools.arc / EMMLIB.ARC / EMM16_C.ASM < prev    next >
Assembly Source File  |  1990-02-04  |  7KB  |  125 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM16_C.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   get_partial_context_size                                ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function returns the storage requirements for the  ;
  7. ;                     structure passed by the get_partial_context and         ;
  8. ;                     set_partial_context functions.  Use this function when  ;
  9. ;                     you want to dynamically allocate this space. This       ;
  10. ;                     function doesn't require an EMM handle.                 ;
  11. ;                                                                             ;
  12. ;           PASSED:   pcl.mappable_region_count:                              ;
  13. ;                        is the number of pages in the partial map to be      ;
  14. ;                        saved by the get_partial_context &                   ;
  15. ;                        set_partial_context functions.  This number should   ;
  16. ;                        be the same as the mappable_region_count structure   ;
  17. ;                        member in the get_partial_context function.          ;
  18. ;                                                                             ;
  19. ;                     &partial_context_size:                                  ;
  20. ;                        is a far pointer to the size of the mapping context  ;
  21. ;                        structure.                                           ;
  22. ;                                                                             ;
  23. ;         RETURNED:   status:                                                 ;
  24. ;                        is the status EMM returns from the call.  All other  ;
  25. ;                        returned results are valid only if the status        ;
  26. ;                        returned is zero.  Otherwise they are undefined.     ;
  27. ;                                                                             ;
  28. ;                     partial_context_size:                                   ;
  29. ;                        is the number of bytes that will be transferred to   ;
  30. ;                        the application's dest_context area whenever a       ;
  31. ;                        program requests the get_partial_context function.   ;
  32. ;                                                                             ;
  33. ;                        Normally, you just supply a CONTEXT_STRUCT structure ;
  34. ;                        which contains an array of the largest space         ;
  35. ;                        possible (currently 255 bytes).  However, if you     ;
  36. ;                        want to dynamically allocate the exact amount of     ;
  37. ;                        space required to save a context, use this           ;
  38. ;                        function to get the size needed (see example below). ;
  39. ;                                                                             ;
  40. ;                        The size of the dest_context depends on the expanded ;
  41. ;                        memory system configuration and the implementation   ;
  42. ;                        of the expanded memory manager.  Therefore, it will  ;
  43. ;                        vary between hardware configurations and  memory     ;
  44. ;                        manager implementations.                             ;
  45. ;                                                                             ;
  46. ; C USE CONVENTION:   unsigned int                status;                     ;
  47. ;                     unsigned int                partial_context_size;       ;
  48. ;                     PARTIAL_CONTEXT_LIST_STRUCT pcl [MAX_MAPPABLE_REGIONS]; ;
  49. ;                     void                        *context;                   ;
  50. ;                                                                             ;
  51. ;                     pcl.mappable_region_count = 2;                          ;
  52. ;                     status = get_partial_context_size                       ;
  53. ;                                               (pcl.mappable_region_count,   ;
  54. ;                                                &partial_context_size);      ;
  55. ;                     if (status == PASSED)                                   ;
  56. ;                     {                                                       ;
  57. ;                        context = malloc (partial_context_size);             ;
  58. ;                        if (context == NULL)                                 ;
  59. ;                           /* error condition (no memory to allocate) */     ;
  60. ;                        else                                                 ; 
  61. ;                        {                                                    ;
  62. ;                           status = get_partial_context                      ;
  63. ;                                               ((CONTEXT_STRUCT *) context); ;
  64. ;                           if (status == PASSED)                             ;
  65. ;                              printf ("context saved\n");                    ;
  66. ;                           else                                              ;
  67. ;                              /* error condition */                          ;
  68. ;                        }                                                    ;
  69. ;                     }                                                       ;
  70. ;                     else                                                    ;
  71. ;                        /* error condition */                                ;
  72. ;-----------------------------------------------------------------------------;
  73. .XLIST
  74. PAGE    60,132
  75.  
  76. IFDEF SMALL
  77.    .MODEL SMALL, C
  78. ENDIF
  79. IFDEF MEDIUM
  80.    .MODEL MEDIUM, C
  81. ENDIF
  82. IFDEF LARGE
  83.    .MODEL LARGE, C
  84. ENDIF
  85. IFDEF COMPACT
  86.    .MODEL COMPACT, C
  87. ENDIF
  88. IFDEF HUGE
  89.    .MODEL HUGE, C
  90. ENDIF
  91.  
  92. INCLUDE emmlib.equ
  93. INCLUDE emmlib.str
  94. INCLUDE emmlib.mac
  95. .LIST
  96. .CODE
  97.  
  98. get_partial_context_size    PROC                                          \
  99.                 context_struct_count:WORD,                    \
  100.                 ptr_context_size:FAR PTR WORD
  101.  
  102.     ;---------------------------------------------------------------------;
  103.     ;   do;                                                               ;
  104.     ;   .   get the size of the partial map context which EMM returns;    ;
  105.     ;---------------------------------------------------------------------;
  106.     MOVE        AX, get_size_p_page_map_array_fcn
  107.     MOVE        BX, context_struct_count
  108.     INT         EMM_int
  109.  
  110.     ;---------------------------------------------------------------------;
  111.     ;   .   pass the size of the partial map context back to the caller;  ;
  112.     ;---------------------------------------------------------------------;
  113.     MOVE        ES:BX, ptr_context_size
  114.     MOVE        ES:[BX], AX
  115.  
  116.     ;---------------------------------------------------------------------;
  117.     ;   .   return (EMM status);                                          ;
  118.     ;   end;                                                              ;
  119.     ;---------------------------------------------------------------------;
  120.     RET_EMM_STAT    AH
  121.  
  122. get_partial_context_size    ENDP
  123.  
  124. END
  125.